/**
 * 
 */
package com.cqwu.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author 黑客LK
 * @time  2015-11-21 下午4:18:38
 */
public class Test {

	public static void main(String[] args) {
		
		String str = "http://localhost:8080/commZone/test/getUser.action?pageNum=3";
		System.out.println(str.contains("?"));
		System.out.println(str.indexOf("?", 1));
		System.out.println(str.substring(0,str.indexOf("?", 1)));
		/*
		int[] arr = {1,3,7,5,2,8,9,6,4};
		Map<Integer, List<String>> map = new HashMap<Integer, List<String>>();
		int count = 0;
		long time1 = System.currentTimeMillis();
		for(int n=2;n<=arr.length;n++){

			if(map.containsKey(n-1)){
				List<String> list = new ArrayList();
				List<String> lastList = map.get(n-1);
				for (int i = 0; i < lastList.size()-1; i++) {
					String str =  lastList.get(i);
					//if(str=="#") continue;
					int index = getIndex(arr, Integer.parseInt(str.substring(str.length()-1)));
					for(int j=index+1;j<arr.length;j++){
						list.add(str+arr[j]);
					}
				}
				
				map.put(n, list);
			}else{
				List<String> list = new ArrayList();
				for(int i=0;i<arr.length-1;i++){
					for(int j=i+1;j<arr.length;j++){
						list.add(arr[i]+""+arr[j]);
					}
				}
				map.put(n, list);
			}
			
		}
		
		Set<java.util.Map.Entry<Integer, List<String>>> set =  map.entrySet();
		for (java.util.Map.Entry<Integer, List<String>> entry : set) {
			List<String> list = entry.getValue();
			for (String string : list) {
				System.out.println(string);
				
				if(isOK(string))
					count++;
			}
		}
		System.out.println(count);
		System.out.println("共运行 "+(System.currentTimeMillis()-time1)+" 毫秒！");*/
	}
	
	public static int getIndex(int arr[],int num){
		int index = 0;
		for (int i = 0; i < arr.length; i++) {
			if(arr[i]==num){
				index =  i;
				break;
			}
		}
		return index;
	}
	public static boolean isOK(String str){
		boolean flag = true;
		for(int i=0;i<str.length()-1;i++){
			if(Math.abs(Integer.parseInt(str.substring(i, i+1))-Integer.parseInt(str.substring(i+1, i+2)))>2){
				flag = false;
				break;
			}
		}
		return flag;
	}
}
